package com.yk.ykmessagesdk;

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Toast;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import com.yk.ykmessagesdk.bean.PayBean;
import com.yk.ykmessagesdk.callback.PayResultListener;
import com.yk.ykmessagesdk.utils.Config;
import com.yk.ykmessagesdk.utils.PayManager;

public class TestActivity extends AppCompatActivity {

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_test);

        findViewById(R.id.btn_pay).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Config config = new Config();
                config.setLogSwitch(true);
                config.setSecretKey("6HWQdoCEfUmI6XgQ");
                PayManager.getInstance().init(TestActivity.this,config);

                PayBean payBean = new PayBean();
                payBean.merid = "9996";
                payBean.goodsid = "208";
                payBean.goodsName = "xxx_vip";
                payBean.amount = 1;
                payBean.amttype = "VND";
                payBean.isShowConfirmActivity = true;

                PayManager.getInstance().pay(TestActivity.this, payBean, new PayResultListener() {
                    @Override
                    public void onResult(int code, String msg) {
                        if (code == 0){
                            runOnUiThread(() -> Toast.makeText(TestActivity.this,"支付成功!",Toast.LENGTH_SHORT).show());
                        }
                        Log.i("TAG",msg);
                    }
                });
            }
        });
    }


    @Override
    protected void onResume() {
        super.onResume();



    }
}
